Expand description
Serde support for the humantime
crate.
Based on this fork.
Currently std::time::{Duration, SystemTime}
are supported.
§Example
use serde::{Serialize, Deserialize};
use std::time::{Duration, SystemTime};
#[derive(Serialize, Deserialize)]
struct Foo {
#[serde(with = "humantime_serde")]
timeout: Duration,
#[serde(default)]
#[serde(with = "humantime_serde")]
time: Option<SystemTime>,
}
Or use the Serde
wrapper type:
use serde::{Serialize, Deserialize};
use humantime_serde::Serde;
use std::time::SystemTime;
#[derive(Serialize, Deserialize)]
struct Foo {
timeout: Vec<Serde<SystemTime>>,
}
Modules§
- Convenience module to allow serialization via
humantime_serde
forOption
- Reexport module.
Structs§
- A wrapper type which implements
Serialize
andDeserialize
for types involvingSystemTime
andDuration
.
Functions§
- Deserializes a
Duration
orSystemTime
via the humantime crate. - Serializes a
Duration
orSystemTime
via the humantime crate.